<template>
  <el-card shadow="never" class="aui-card--fill">
    <h3 v-if="showNo" style="marginTop: 0">{{ $route.params.mtNo }}</h3>
    <div class="mod-wms__purchase-detail}">
      <!-- <el-upload
            class="upload-demo"
            multiple
            :limit="3"
            :on-exceed="handleExceed">
            <el-button size="small" type="primary">导入</el-button>
          </el-upload> -->
      <wms-form v-model="dataForm" :formList="formList" :table-column="tableColumn" :advanced="advanced"
        @check-change="checkChange" @changeAdvance="changeAdvance" @getDataList="getDataList" @getReset="getReset">
        <el-form-item label="入库时间">
          <el-date-picker v-model="dateRange" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange"
            range-separator="-" start-placeholder="开始" end-placeholder="结束" :picker-options="pickerOptions"
            @change="query">
          </el-date-picker>
          <el-button type="primary" plain @click="exportHandle" style="margin-left: 10px;">导出
          </el-button>
       </el-form-item>
      </wms-form>
      <wms-table ref="wmsTable" v-model="dataForm" :page="page" :total="total" :limit="limit" :tableData="dataList"
        :table-column="column" :module-options="mixinViewModuleOptions" :dataListLoading="dataListLoading"
        :showSelection="true" @deleteHandle="deleteHandle" @addOrUpdateHandle="addOrUpdateHandle"
        @pageSizeChangeHandle="pageSizeChangeHandle" @pageCurrentChangeHandle="pageCurrentChangeHandle"
        @dataListSelectionChangeHandle="dataListSelectionChangeHandle" />
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './components/purchase-detail-add-or-update'
import { formList, tableColumn } from './config'
import wmsTable from '@/components/wms-table'
import wmsForm from '@/components/wms-form'
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        createdIsNeed: false,
        getDataListURL: '/wms/purchase-detail/page',
        getDataListIsPage: true,
        exportURL: '/wms/purchase-detail/export',
        deleteURL: '/wms/purchase-detail',
        deleteIsBatch: true,
        deleteIsBatchKey: 'detailId'
      },
      showNo: false,
      formList,
      tableColumn,
      dataForm: {
        detailId: '',
        purchaseId: '',
        spuNo: '',
        stockType:''
      },
      dateRange:[],
    }
  },
  components: {
    AddOrUpdate,
    wmsTable,
    wmsForm
  },
  created() {
    if (this.$route.params.dtId) {
      this.showNo = true
      this.dataForm.purchaseId = this.$route.params.dtId
    }
    this.query()
  },
  computed: {
    pickerOptions() {
      return {
        // onPick绑定点击事件
        onPick: this.query()
      }
    }
  },
 
  methods: {
    //0.重置搜索框
    getReset() {
      this.dataForm = this.$options.data().dataForm;
    }
  },
}
</script>
